@model WorkFlowCore.BusinessDemo.Web.Models.AssignRolesViewModel

@{
    ViewData["Title"] = "分配角色";
}

<h2>为用户 @Model.UserName 分配角色</h2>

<hr />
<div class="row">
    <div class="col-md-6">
        <form asp-action="AssignRoles">
            <input type="hidden" asp-for="UserId" />
            <div class="form-group">
                <h5>可选角色</h5>
                @for (int i = 0; i < Model.AvailableRoles.Count; i++)
                {
                    <div class="form-check">
                        <input type="hidden" asp-for="@Model.AvailableRoles[i].RoleId" />
                        <input type="hidden" asp-for="@Model.AvailableRoles[i].RoleName" />
                        <input class="form-check-input" type="checkbox" 
                               id="role_@Model.AvailableRoles[i].RoleId" 
                               asp-for="@Model.AvailableRoles[i].IsSelected"
                               name="AvailableRoles[@i].IsSelected">
                        <label class="form-check-label" for="role_@Model.AvailableRoles[i].RoleId">
                            @Model.AvailableRoles[i].RoleName
                        </label>
                    </div>
                }
            </div>
            <div class="form-group mt-3">
                <input type="submit" value="保存" class="btn btn-primary" />
                <a asp-action="Details" asp-route-id="@Model.UserId" class="btn btn-secondary">返回详情</a>
            </div>
        </form>
    </div>
</div>
